package jacker.bit.price;

import org.json.JSONObject;

import android.content.Context;

public class PlatformHuobi implements Platform {

	@Override
	public String getCode() {
		return "huobi";
	}

	@Override
	public String getName(Context ctx) {
		return ctx.getString(R.string.platform_huobi);
	}

	@Override
	public float getPrice() throws Exception{
		//String result = PriceChecker.httpGetLimit("https://market.huobi.com/staticmarket/detail.html");
		//int start = result.indexOf("price");
		//int end = result.indexOf(",",start)-1;
		//return Float.parseFloat(result.substring(start+8,end));
		String result = PriceChecker.httpGet("http://market.huobi.com/staticmarket/ticker_btc_json.js");
		JSONObject json = new JSONObject(result);
		return Float.parseFloat(json.getJSONObject("ticker").getString("last"));
		//String result = PriceChecker.httpGet("http://www.btc123.com/e/interfaces/tickers.php?type=huobiTicker");
		//JSONObject json = new JSONObject(result);
		//return Float.parseFloat(json.getJSONObject("ticker").getString("last"));
	}

	@Override
	public String getCurrency() {
		// TODO Auto-generated method stub
		return "¥";
	}
	
	

}
